package org.snia.cdmi.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class DataObjectVersion {

    /** 版本ID */
    private String versionId = null;
    /** 创建时间 */
    private Date creationDate = null;
    /** 版本状态*/
    private VersionStatus status;
    /** 该版本所对应的分片数据信息*/
    private List<String> slices;
    
	/**
	 * @param creationDate the creationDate to set
	 */
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
	/**
	 * @return the creationDate
	 */
	public Date getCreationDate() {
		return creationDate;
	}
	/**
	 * @param slices the slices to set
	 */
	public void setSlices(List<String> slices) {
		this.slices = slices;
	}
	
	public void setNewSlice(String md5) {
		if(this.slices == null)
			this.slices = new ArrayList<String>();
		this.slices.add(md5);
	}
	/**
	 * @return the slices
	 */
	public List<String> getSlices() {
		return slices;
	}
	
	/**
	 * @param status the status to set
	 */
	public void setStatus(VersionStatus status) {
		this.status = status;
	}
	/**
	 * @return the status
	 */
	public VersionStatus getStatus() {
		return status;
	}

	/**
	 * @param versionId the versionId to set
	 */
	public void setVersionId(String versionId) {
		this.versionId = versionId;
	}
	/**
	 * @return the versionId
	 */
	public String getVersionId() {
		return versionId;
	}

	public enum VersionStatus{
		Normal (0),	//正常状态	
		Merger(1),	//合并状态
		Delete(-3);	//删除状态
		
	    private final int state;

	    private VersionStatus(int state) {
	        this.state = state;
	    }
	    
	    /* (non-Javadoc)
	     * @see java.lang.Enum#toString()
	     */
	    @Override
	    public String toString() {
	        return String.valueOf(this.state);
	    }
	    
	    public int getValue() {
	        return this.state;
	    }
	}
}

